require_relative 'CPFService'
require_relative 'StringUtils'

class LoginService < CPFService
	LOGIN_REQUEST = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:log="http://schemas.cordys.com/cpf/login"><soapenv:Header/><soapenv:Body><log:CordysLogin><log:serverurl>{serverurl}</log:serverurl><log:username>{username}</log:username><log:password>{password}</log:password></log:CordysLogin></soapenv:Body></soapenv:Envelope>'
	include StringUtils

	def initialize
		super
		requestMap = {}
		requestMap[/\{serverurl\}/] = @@properties["serverurl"]
		requestMap[/\{username\}/] = @@properties["username"]
		requestMap[/\{password\}/] = @@properties["password"]
		@request = replaceMap LOGIN_REQUEST, requestMap
	end

	def assertion
		@assertion = getFromResponse(".//*[local-name() = 'AssertionArtifact']")[0]
	end
end